package java7_26;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Filezuoye5 {
	public static void main(String[] args) throws Exception {
		File file = new File("text");
		FileInputStream fileInputStream = new FileInputStream(file);
		FileOutputStream FileOutputStream=new FileOutputStream(file);
		ArrayList<Character> list=new ArrayList<>();
		byte[] b=new byte[1];
		int len=0;
		while((len=fileInputStream.read(b))!=-1){
			list.add((char)b[0]);
		}
		fileInputStream.close();
		String collect = list.stream().filter(t->t!='-').sorted().map(t->t+"").collect(Collectors.joining("-"));
		byte[] bytes = collect.getBytes();
		//FileOutputStream FileOutputStream=new FileOutputStream(file);
		FileOutputStream.write(bytes, 0, bytes.length);
		FileOutputStream.close();
		System.out.println(collect);
	}
}
